/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;
import EntityBean.*;

import java.util.Date;
import java.util.List;
import javax.sql.*;
import javax.servlet.http.*;

/**
 *
 * @author
 */
public class BookController extends HttpServlet{
//    private Trip trip;
    private String receipt;
//    private ArrayList seatLsit;
//    private ArrayList flightSeats;

//    public List getFreeSeat(FlightEB flight){
//        List<seatInstanceEB>
//
//        return seatList;
//    }

    public List bookTrip(FlightInstance flight){

        List<SeatInstance> availableSeats = flight.getFreeSeats();

        //Change to right form
        return availableSeats;
    }


    public String bookSeat(List<SeatInstance> seats, List<String> names, List<Integer> pNumbers){
        Trip trip = new Trip();


        //
        Passenger pass = new Passenger();
        //
        pass.create(names.get(0), pNumbers.get(0), seats.get(0), 1);

        seats.get(0).setEmpty(false);

        trip.addPass(pass);

        receipt += trip.getNumber()+" "+ names.get(0) +" \n";

        for(int i = 1; i<=seats.size(); i++){
            pass = new Passenger();

            pass.create(names.get(i), pNumbers.get(i), seats.get(i), 1);

            seats.get(i).setEmpty(false);

            trip.addPass(pass);

            receipt += names.get(0) +" \n";
        }


        return receipt;
    }
//
//    public void addToReceipt(int nr, String row, String pName, String pNumber, int tripNr){
//
//    }
}
